﻿
Imports System.IO

Public Class autoflushFileStream2
    Inherits autoflushFileStream

    Private timer3Index As Guid = Nothing

    Public Sub New(ByVal path As String, ByVal mode As FileMode, ByVal access As FileAccess, ByVal share As FileShare _
                   , ByVal interval As Int64)
        MyBase.New(path, mode, access, share)
        timer3Index = timer3.addcall(AddressOf Flush, interval)
        assert(timer3Index <> Guid.Empty, "cannot add call to timer3.")
    End Sub

    Public Sub New(ByVal path As String, ByVal mode As FileMode, ByVal access As FileAccess, ByVal share As FileShare)
        MyBase.New(path, mode, access, share)
        timer3Index = timer3.addcall(AddressOf Flush, 16000)
    End Sub

    Public Overrides Sub Close()
        If timer3Index <> Guid.Empty Then
            debugassert(timer3.removecall(timer3Index), "cannot remove timer3 call.")
            timer3Index = Guid.Empty
        End If
        MyBase.Close()
    End Sub
End Class
